/**************************************************************************
 *
 * Copyright (c) 2015-2017  QIKU Company             　　　　　　　            
 *                 奇酷软件（深圳）有限公司  版权所有 2015-2017
 *
 * PROPRIETARY RIGHTS of QIKU Company are involved in the  　　　　　　     
 * subject matter of this material.  All manufacturing, reproduction, use, 
 * and sales rights pertaining to this subject matter are governed by the  
 * license agreement.  The recipient of this software implicitly accepts   
 * the terms of the license.                                               
 * 本软件文档资料是奇酷公司的资产,任何人士阅读和使用本资料必须获得                     
 * 相应的书面授权,承担保密责任和接受相应的法律约束.                                 
 *
 **************************************************************************/
package com.yw.android.common.filelogger;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 打印异常堆栈
 *
 * @author yuanwei
 */
public class StackTracePrinter {
    /**
     * 获取异常堆栈信息，以字符串的方式
     *
     * @param t 异常
     * @return 异常堆栈信息
     */
    public static String getStackTrace(Throwable t) {
        if (null != t) {
            StringWriter sw = new StringWriter();
            t.printStackTrace(new PrintWriter(sw));
            return sw.toString();
        } else {
            return "";
        }
    }
}
